<?php

use App\Models\Activity\ActivityModel;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateActivity extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('activity', function (Blueprint $table) {
            $table->id();

            $table->string("name", 120)->comment("活动名称")->default("");
            $table->unsignedTinyInteger("activityType")->comment(
                enumToMigrationComment(ActivityModel::ACTIVITY_TYPE_TEXT, "活动类型")
            )->default(0);
            $table->unsignedTinyInteger("shopType")->comment(
                enumToMigrationComment(ActivityModel::SHOP_TYPE_TEXT, "门店类型")
            )->default(0);
            $table->json("joinShopIds")->comment("部分参与门店配置")->nullable(true);
            $table->unsignedTinyInteger("expireType")->comment(
                enumToMigrationComment(ActivityModel::EXPIRE_TYPE_TEXT, "有效期类型")
            )->default(0);
            $table->unsignedBigInteger("startTime")->comment("开始时间")->default(0);
            $table->unsignedBigInteger("endTime")->comment("截止时间")->default(0);
            $table->json("joinRestrict")->comment("参与限制")->nullable(true);
            $table->json("blackShopIds")->comment("黑名单门店")->nullable(true);
            $table->json("whiteShopIds")->comment("白名单门店")->nullable(true);

            $table->string("popUpTitle", 120)->comment("弹出标题")->default("");
            $table->text("popUpContent")->comment("弹出内容")->default("");


            $table->unsignedTinyInteger("superScreenSwitch")->comment(
                enumToMigrationComment(ActivityModel::SWITCH_TEXT, "首页霸屏开关")
            )->default(0);
            $table->unsignedBigInteger("superScreenStartTime")->comment("霸屏开始时间")->default(0);
            $table->unsignedBigInteger("superScreenEndTime")->comment("霸屏结束时间")->default(0);
            $table->unsignedTinyInteger("superScreenFrequency")->comment(
                enumToMigrationComment(ActivityModel::SUPER_SCREEN_FREQUENCY_TEXT, "霸屏频次")
            )->default(0);
            $table->string("superScreenBeforeContent")->comment("霸屏前提示内容")->default("");
            $table->string("superScreenAfterContent")->comment("霸屏后提示内容")->default("");

            $table->text("detail")->comment("活动详情 - 富文本")->default("");
            $table->string("remark")->comment("活动备注")->default("");

            $table->unsignedTinyInteger("feedbackImgSwitch")->comment(
                enumToMigrationComment(ActivityModel::SWITCH_TEXT, "回传照片开关")
            )->default(ActivityModel::SWITCH_ON);
            $table->json("feedbackExampleImages")->comment("回传示例照片")->nullable(true);
            $table->unsignedTinyInteger("remindSwitch")->comment(
                enumToMigrationComment(ActivityModel::SWITCH_TEXT, "提醒开关")
            )->default(ActivityModel::SWITCH_ON);

            $table->unsignedBigInteger("remindStartTime")->comment("提醒开始时间")->default(0);
            $table->unsignedBigInteger("remindEndTime")->comment("提醒结束时间")->default(0);
            $table->unsignedBigInteger("systemNotifyCenterId")->comment("消息id system_notify_center.id")->default(0);
            $table->time("remindDailyTime")->comment("每日通知时间")->default("00:00:00");
            $table->string("remindCycle", 120)->comment("通知周期")->default("");

            $table->unsignedTinyInteger("status")->comment(
                enumToMigrationComment(ActivityModel::STATUS_TEXT, "活动状态")
            )->default(0);
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');

            $table->unsignedTinyInteger('isDeleted')->default(0)->comment('是否删除 0 否 1是');

            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '活动 - 主表';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('activity');
    }
}
